package com.everydayflash.cart.mods {

	/**
	 * @author bartekd
	 */
	public class Walking {

		// Read values
		public var legsOffset:Number = Math.PI;
		public var base:Number = 0;
		public var bounce:Number;

		public var leftThigh:Number;		public var leftCalf:Number;			public var rightThigh:Number;		public var rightCalf:Number;

		// Write values
		private var _speed:Number = 0;
		public var bounceRange:Number = 0;
		public var thighRange:Number = 0;
		public var calfRange:Number = 0;
		public var calfOffset:Number = Math.PI / -2;

		private var cycle:Number;		public function Walking() {
			cycle = 0;
		}

		public function walk():void {
			cycle += _speed;
			leftThigh = Math.sin(cycle) * thighRange;
			leftCalf = Math.sin(cycle + calfOffset) * calfRange + calfRange;
			rightThigh = Math.sin(cycle + legsOffset) * thighRange;
			rightCalf = Math.sin(cycle + legsOffset + calfOffset) * calfRange + calfRange;
			
			bounce = Math.sin(cycle * 2) * bounceRange;
		}				public function get speed():Number {
			return _speed;		}				public function set speed(s:Number):void {
			_speed = Math.pow(s * .1, .5);
			thighRange = -Math.pow(Math.PI / 4 * s, 1);
			calfRange = -Math.pow(Math.PI / 4 * s, 1);
			bounceRange = s * s * .25;
			base = Math.pow(s, 3) * Math.PI / -12;		}
	}
}



